var should = require('chai').should();
var webdriver = require('selenium-webdriver');
var By = webdriver.By;

//var builder = new webdriver.Builder().usingServer("http://127.0.0.1:4444/wd/hub");
//System.setProperty("webdriver.firefox.bin", "F:\\Mozilla Firefox\\firefox.exe");
//System.setProperty("webdriver.gecko.driver", "F:\\Mozilla Firefox\\geckodriver.exe");
//builder.withCapabilities({
//	browserName: "firefox"
//});
var driver = new webdriver.Builder()
	.forBrowser('firefox')
	.usingServer('http://localhost:4444/wd/hub') //注意这里
	.build();


describe('页面跳转测试', function() {
	beforeEach(function() {});

	afterEach(function() {
		driver.close();
		driver.quit();
	});

	it('登陆，资源广场，用户反馈，联机帮助页面跳转', function(done) {
		driver.get('http://47.95.218.7:3000');
		driver.findElement(By.css('#lst-ib')).sendKeys('mocha');
		driver.findElement(By.name("name")).click();
		driver.findElement(By.name("name")).clear();
		driver.findElement(By.name("name")).sendKeys("5120152499");
		driver.findElement(By.xpath("//body")).click();
		driver.findElement(By.name("password")).click();
		driver.findElement(By.name("password")).clear();
		driver.findElement(By.name("password")).sendKeys("5120152499");
		driver.findElement(By.xpath("//body")).click();
		driver.findElement(By.id("loginbt")).click();
		driver.findElement(By.linkText("资源广场")).click();
		driver.findElement(By.linkText("用户反馈")).click();
		driver.findElement(By.linkText("联机帮助")).click();
		done();
	});

	it('快速选择专业，日期，格式', function() {
		driver.get("http://47.95.218.7:3000/main");
		driver.findElement(By.xpath("//ul[@id='major']/li")).click();
		driver.findElement(By.xpath("//ul[@id='date']/li")).click();
		driver.findElement(By.xpath("//ul[@id='type']/li")).click();
		driver.findElement(By.xpath("//ul[@id='type']/li[2]")).click();
		driver.findElement(By.xpath("//ul[@id='type']/li[3]")).click();
		driver.findElement(By.xpath("//ul[@id='date']/li[3]")).click();
		driver.findElement(By.xpath("//ul[@id='major']/li[3]")).click();
	});

	it('翻页，文件预览，文件收藏，评分', function() {
		driver.get("http://47.95.218.7:3000/main");
    driver.findElement(By.xpath("//div[@id='content']/div/a/div[2]")).click();
    driver.findElement(By.linkText("资源广场")).click();
    driver.findElement(By.id("nextPage")).click();
    driver.findElement(By.xpath("//div[@id='content']/div[2]/a/header")).click();
    driver.findElement(By.xpath("//div[@id='like']/img")).click();
    driver.findElement(By.xpath("//div[@id='score']/img[3]")).click();
    driver.findElement(By.xpath("//div[@id='score']/p")).click();
	});
});